# -*-  coding:utf-8 -*-
# Author : lihongliang


with open ("username.txt","r") as f_user,\
        open("lockname.txt","r")as f_lock:
    lock_user = f_lock.read().split(",")
    user_lis_dict = {}
    for i in f_user:
        user_lis_dict.setdefault(i.split(",")[0],i.split(",")[1])
        print(i)

count = 0

for i in range(5):
    name = input ("请输入用户名：")
    password = input("请输入密码：")
    if name  in lock_user:
        print("账户已被锁定，请联系管理员！")
        continue

    elif name in user_lis_dict:
        print(name)
        print(user_lis_dict.get(name))
        if password == user_lis_dict.get(name):
            print("欢迎--",name ,"--登录系统")
            break
        else:
            if count ==2:
                f_balck_name = open("lockname.txt","a",encoding="utf-8")
                f_balck_name.write(name+',')
                f_balck_name.close()
                print("错误次数过多，用户名已经锁定，请联系管理员")
                break
            print("密码错误！")
            count += 1
    else:
        if i == 4:
            print("错误次数过多，再见！")
            continue
        print("用户名不存在")